{include file="common/_header-css"}
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form action="" method="post" class="layui-form layui-form-pane">
            <div class="layui-form-item">
                <label for="account" class="layui-form-label">
                    <span class="x-red">*</span>账号
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="account" name="account" required="" lay-verify="required"
                           autocomplete="off" class="layui-input" placeholder="请输入管理员账号">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="account" class="layui-form-label">
                    <span class="x-red">*</span>管理员昵称
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="username" name="username" required="" lay-verify="required"
                           autocomplete="off" class="layui-input" placeholder="请输入管理员昵称">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="account" class="layui-form-label">
                    <span class="x-red">*</span>密码
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="password" name="password" required="" lay-verify="required"
                           autocomplete="off" class="layui-input" placeholder="请输入管理员密码">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="account" class="layui-form-label">
                    <span class="x-red">*</span>选择权限组
                </label>
                <div class="layui-input-inline">
                    <select name="group_id">
                        {volist name="group" id="vo"}
                        <option value="{$vo.id}">{$vo.title}</option>
                        {/volist}
                    </select>
                </div>
            </div>
            <input type="hidden" name="type" value="1">
            <div class="layui-form-item">
                <button class="layui-btn" lay-submit="" lay-filter="add">增加</button>
            </div>
        </form>
    </div>
</div>

{include file="common/_jQuery"}
<script>
</script>

<script>
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;

        form.on('submit(add)', function(data){
            $.post("{:url('permissions/administrator_curd')}",data.field,function (res) {
                if (res.code == 200) {
                    layer.alert(res.msg, {icon: 6}, function () {
                        // 获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
                    });
                }else{
                    layer.alert(res.msg, {icon: 5});
                }
            });
            return false;
        });
        form.on('checkbox(father)', function(data){
            if(data.elem.checked){
                $(data.elem).parent().siblings('td').find('input').prop("checked", true);
                form.render();
            }else{
                $(data.elem).parent().siblings('td').find('input').prop("checked", false);
                form.render();
            }
        });
    });
</script>
</body>

</html>